<?php

/**
 * Application Models
 *
 * @package Application_Model
 * @subpackage Model
 * @author <YOUR NAME HERE>
 * @copyright ZF model generator
 * @license http://framework.zend.com/license/new-bsd     New BSD License
 */

/**
 * Abstract class for models
 */
require_once 'ModelAbstract.php';

/**
 * 
 *
 * @package Application_Model
 * @subpackage Model
 * @author <YOUR NAME HERE>
 */
class Application_Model_Usersprojets extends Application_Model_ModelAbstract
{

    /**
     * Database var type int(11)
     *
     * @var int
     */
    protected $_Idusersprojets;

    /**
     * Database var type int(11)
     *
     * @var int
     */
    protected $_Idusers;

    /**
     * Database var type int(11)
     *
     * @var int
     */
    protected $_Idprojetregional;


    /**
     * Parent relation fk_usersprojets_users1
     *
     * @var Application_Model_Users
     */
    protected $_Users;

    /**
     * Parent relation fk_usersprojets_projetregional1
     *
     * @var Application_Model_Projetregional
     */
    protected $_Projetregional;


    /**
     * Sets up column and relationship lists
     */
    public function __construct()
    {
        parent::init();
        $this->setColumnsList(array(
            'idusersprojets'=>'Idusersprojets',
            'idusers'=>'Idusers',
            'idprojetregional'=>'Idprojetregional',
        ));

        $this->setParentList(array(
            'FkUsersprojetsUsers1'=> array(
                    'property' => 'Users',
                    'table_name' => 'Users',
                ),
            'FkUsersprojetsProjetregional1'=> array(
                    'property' => 'Projetregional',
                    'table_name' => 'Projetregional',
                ),
        ));

        $this->setDependentList(array(
        ));
    }

    /**
     * Sets column idusersprojets
     *
     * @param int $data
     * @return Application_Model_Usersprojets
     */
    public function setIdusersprojets($data)
    {
        $this->_Idusersprojets = $data;
        return $this;
    }

    /**
     * Gets column idusersprojets
     *
     * @return int
     */
    public function getIdusersprojets()
    {
        return $this->_Idusersprojets;
    }

    /**
     * Sets column idusers
     *
     * @param int $data
     * @return Application_Model_Usersprojets
     */
    public function setIdusers($data)
    {
        $this->_Idusers = $data;
        return $this;
    }

    /**
     * Gets column idusers
     *
     * @return int
     */
    public function getIdusers()
    {
        return $this->_Idusers;
    }

    /**
     * Sets column idprojetregional
     *
     * @param int $data
     * @return Application_Model_Usersprojets
     */
    public function setIdprojetregional($data)
    {
        $this->_Idprojetregional = $data;
        return $this;
    }

    /**
     * Gets column idprojetregional
     *
     * @return int
     */
    public function getIdprojetregional()
    {
        return $this->_Idprojetregional;
    }

    /**
     * Sets parent relation Idusers
     *
     * @param Application_Model_Users $data
     * @return Application_Model_Usersprojets
     */
    public function setUsers(Application_Model_Users $data)
    {
        $this->_Users = $data;

        $primary_key = $data->getPrimaryKey();
        if (is_array($primary_key)) {
            $primary_key = $primary_key['idusers'];
        }

        $this->setIdusers($primary_key);

        return $this;
    }

    /**
     * Gets parent Idusers
     *
     * @param boolean $load Load the object if it is not already
     * @return Application_Model_Users
     */
    public function getUsers($load = true)
    {
        if ($this->_Users === null && $load) {
            $this->getMapper()->loadRelated('FkUsersprojetsUsers1', $this);
        }

        return $this->_Users;
    }

    /**
     * Sets parent relation Idprojetregional
     *
     * @param Application_Model_Projetregional $data
     * @return Application_Model_Usersprojets
     */
    public function setProjetregional(Application_Model_Projetregional $data)
    {
        $this->_Projetregional = $data;

        $primary_key = $data->getPrimaryKey();
        if (is_array($primary_key)) {
            $primary_key = $primary_key['idprojetregional'];
        }

        $this->setIdprojetregional($primary_key);

        return $this;
    }

    /**
     * Gets parent Idprojetregional
     *
     * @param boolean $load Load the object if it is not already
     * @return Application_Model_Projetregional
     */
    public function getProjetregional($load = true)
    {
        if ($this->_Projetregional === null && $load) {
            $this->getMapper()->loadRelated('FkUsersprojetsProjetregional1', $this);
        }

        return $this->_Projetregional;
    }

    /**
     * Returns the mapper class for this model
     *
     * @return Application_Model_Mapper_Usersprojets
     */
    public function getMapper()
    {
        if ($this->_mapper === null) {
            $this->setMapper(new Application_Model_Mapper_Usersprojets());
        }

        return $this->_mapper;
    }

    /**
     * Deletes current row by deleting the row that matches the primary key
     *
	 * @see Application_Model_Mapper_Usersprojets::delete
     * @return int|boolean Number of rows deleted or boolean if doing soft delete
     */
    public function deleteRowByPrimaryKey()
    {
        if ($this->getIdusersprojets() === null) {
            throw new Exception('Primary Key does not contain a value');
        }

        return $this->getMapper()
                    ->getDbTable()
                    ->delete('idusersprojets = ' .
                             $this->getMapper()
                                  ->getDbTable()
                                  ->getAdapter()
                                  ->quote($this->getIdusersprojets()));
    }
}
